<template lang="">
    <div>
        <van-nav-bar :title="research.title" />
        <van-tabs v-model:active="tab" @click-tab="onClickTab">
            <van-tab title="项目一览" name="base"></van-tab>
            <van-tab title="治疗方案" name="solution"></van-tab>
            <van-tab title="入组患者" name="patient"></van-tab>
            <van-tab title="参研人员" name="doc"></van-tab>
        </van-tabs>
    </div>
</template>
<script>
import { ref, reactive,onMounted } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { getResearchDetail} from "../api/index"
import { getUserInfo, log, LOCAL_USER } from "../utils/user"
import { showToast, showConfirmDialog } from 'vant';
export default {
    setup() {
        const router = useRouter()
        const route = useRoute()
        const userInfo = getUserInfo();
        let id = 0;

        const research = reactive({
            id:0,
            title:"",
            purpose:"",
            org:"",
            start_people:"",
            status:"",
            research_nums:"",
            patient_nums:"",
            files:"",
            researcher:"",
            researcher_img:"",
            researcher_org:"",
        })
        const getData = () => {
            getResearchDetail({id:id}).then(res => {
               log("dwd",res)
               if(res.status == 'ok'){
                    research.title = res.data.title;
                    research.purpose = res.data.purpose;
                    research.org = res.data.org;
                    research.start_people = res.data.start_people;
                    research.status = res.data.status;
                    research.research_nums = res.data.research_nums;
                    research.patient_nums = res.data.patient_nums;
                    research.files = res.data.files.split(",");
                    research.researcher = res.data.researcher;
                    research.researcher_img = res.data.researcher_img;
                    research.researcher_org = res.data.researcher_org;
               }else{
                showToast(res.msg)
               }
            })
        }
        onMounted(() => {
            id = route.params.id ? route.params.id : 0
            if(!id){
                router.push("/MyKy")
            }else{
                getData()
            }
        })
        const tab = ref('doc')
        const onClickTab = ({ title,name }) => {
            if(name == 'base'){
                router.push("/KyDetail/"+id)
            }
            if(name == 'solution'){
                router.push("/KySolution/"+id)
            }
            if(name == 'patient'){
                router.push("/KyPatient/"+id)
            }
        };
        const otherProject = () => {
            router.push("/OtherKy")
        }
        const goToDetail = (id) => {
            router.push("/KyDetail/"+id)
        }
        const createProjectDoc = () => {

        }
        return {
            tab,
            onClickTab,
            research,
            otherProject,
            goToDetail,
            createProjectDoc
        }
    }
}
</script>
<style lang="">
    
</style>